/**
* 左边菜单
*/
<template>
  <el-menu :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
    <div class="logobox">
      <img class="logoimg" src="../assets/img/logo.png" alt="">
    </div>
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{menu.menuname}}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item v-for="chmenu in menu.menus" :index="'/'+chmenu.url" :key="chmenu.menuid">
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{chmenu.menuname}}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
export default {
  name: 'leftnav',
  data() {
    return {
      collapsed: false,
      allmenu: [
        {
          menuid: 1,
          icon: 'li-icon-xiangmuguanli',
          menuname: '产品管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 1,
              icon: 'li-icon-xiangmuguanli',
              menuname: '品类管理',
              hasThird: 'N',
              url: 'product/Categories',
              menus: null
            },
            {
              menuid: 2,
              icon: 'li-icon-xiangmuguanli',
              menuname: '产品管理',
              hasThird: 'N',
              url: 'product/Products',
              menus: null
            },
            {
              menuid: 52,
              icon: 'li-icon-xiangmuguanli',
              menuname: 'App定制',
              hasThird: 'N',
              url: 'app/AppDesign',
              menus: null
            }
          ]
        },
        {
          menuid: 33,
          icon: 'li-icon-xiangmuguanli',
          menuname: '设备管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 34,
              icon: 'li-icon-xiangmuguanli',
              menuname: '设备列表',
              hasThird: 'N',
              url: 'device/Devices',
              menus: null
            }
          ]
        },
        {
          menuid: 40,
          icon: 'li-icon-xiangmuguanli',
          menuname: '空间管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 34,
              icon: 'li-icon-xiangmuguanli',
              menuname: '空间列表',
              hasThird: 'N',
              url: 'space/Spaces',
              menus: null
            }
          ]
        },
        {
          menuid: 41,
          icon: 'li-icon-xiangmuguanli',
          menuname: '用户管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 35,
              icon: 'li-icon-xiangmuguanli',
              menuname: '平台用户管理',
              hasThird: 'N',
              url: 'system/Users',
              menus: null
            },
            {
              menuid: 36,
              icon: 'li-icon-xiangmuguanli',
              menuname: 'C端用户管理',
              hasThird: 'N',
              url: 'client/Users',
              menus: null
            }
          ]
        },
        {
          menuid: 61,
          icon: 'li-icon-xiangmuguanli',
          menuname: '三方平台接入',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 62,
              icon: 'li-icon-xiangmuguanli',
              menuname: '天猫精灵接入',
              hasThird: 'N',
              url: 'aligenie/Products',
              menus: null
            }
          ]
        },
        {
          menuid: 71,
          icon: 'li-icon-xiangmuguanli',
          menuname: '数据可见化',
          hasThird: null,
          menus: [
            {
              menuid: 72,
              icon: 'li-icon-xiangmuguanli',
              menuname: '数据大屏',
              hasThird: 'N',
              url: 'dataView/Screen',
              menus: null
            },
            {
              menuid: 73,
              icon: 'li-icon-xiangmuguanli',
              menuname: '数据统计',
              hasThird: 'N',
              url: 'dataView/Statistics',
              menus: null
            }
          ]
        },
        {
          menuid: 81,
          icon: 'li-icon-xiangmuguanli',
          menuname: '规则引擎',
          hasThird: null,
          menus: [
            {
              menuid: 82,
              icon: 'li-icon-xiangmuguanli',
              menuname: '场景联动',
              hasThird: 'N',
              url: 'rule/Scenes',
              menus: null
            },
            {
              menuid: 83,
              icon: 'li-icon-xiangmuguanli',
              menuname: '定时任务',
              hasThird: 'N',
              url: 'rule/Tasks',
              menus: null
            },
          ]
        },
        {
          menuid: 91,
          icon: 'li-icon-xiangmuguanli',
          menuname: '告警中心',
          hasThird: null,
          menus: [
            {
              menuid: 92,
              icon: 'li-icon-xiangmuguanli',
              menuname: '告警列表',
              hasThird: 'N',
              url: 'alarm/Alarms',
              menus: null
            },
            {
              menuid: 93,
              icon: 'li-icon-xiangmuguanli',
              menuname: '告警设置',
              hasThird: 'N',
              url: 'alarm/AlarmSettings',
              menus: null
            }
          ]
        }
      ]
    }
  },
  created() {
    this.$root.Bus.$on('toggle', value => {
      this.collapsed = !value
    })
  }
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
text-align: center;
  background-color: #FFF;
  margin: 5px 10px;
  padding: 5px 0;
  border-radius: 10px;
  box-shadow: 2px 5px #000;
}
.logoimg {
  height: 70px;
}
</style>
